package com.gobang.view;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import com.gobang.control.Controller;

public class ControlPanel extends JPanel {

	private static final long serialVersionUID = 1L;
	private Controller controller;
	private JButton jbStart;
	
	/**
	 * This is the default constructor
	 */
	public ControlPanel(Controller controller) {
		this.controller = controller;
		controller.setControlPanel(this);
		initialize();
	}

	private void initialize() {
		setBackground(Color.LIGHT_GRAY);
		this.setLayout(null);
		JLabel jlPlayer = new JLabel("玩家");
		jlPlayer.setIcon(new ImageIcon(getClass().getResource("/resource/black.png")));
		jlPlayer.setBounds(40, 30, 100, 50);
		add(jlPlayer);
		
		JLabel pcPlayer = new JLabel("电脑");
		pcPlayer.setIcon(new ImageIcon(getClass().getResource("/resource/white.png")));
		pcPlayer.setBounds(40, 100, 100, 50);
		add(pcPlayer);
		
		jbStart = new JButton("新游戏");
		jbStart.setBounds(40, 470, 100, 30);
		jbStart.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				ControlPanel.this.controller.newGame();
			}
		});
		add(jbStart);
	}

	
}
